<?php
	//$type=get_net_param();
	$type=$argv[1];
	if(empty($type)){
		return;
	}else{
		if($type==1){//系统派奖
			get_net_data('http://localhost/mua/Admin/Cron/prize_giving');
		}elseif($type==2){//收入统计
			get_net_data('http://localhost/mua/Admin/Cron/statics');
		}
	}
	/*定时任务 网址不能为虚拟域名 否则无法访问*/	
		function get_net_data($url){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10 );
		curl_exec($ch);
		}
	/*获取网络参数*/	
		function get_net_param(){
			$str=$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
			//1.0 用parse_url解析URL,此处是$str
			$arr = parse_url($str);
			//2.0 将URL中的参数取出来放到数组里
			$arr_query = convertUrlQuery($arr['query']);
			return  $arr_query['type'];
		}	
//3.0 将 参数数组 再变回 字符串形式的参数格式
//var_dump(getUrlQuery($arr_query));
 
 
 function convertUrlQuery($query)
{ 
    $queryParts = explode('&', $query); 
     
    $params = array(); 
    foreach ($queryParts as $param) 
    { 
        $item = explode('=', $param); 
        $params[$item[0]] = $item[1]; 
    } 
     
    return $params; 
}
 
function getUrlQuery($array_query)
{
    $tmp = array();
    foreach($array_query as $k=>$param)
    {
        $tmp[] = $k.'='.$param;
    }
    $params = implode('&',$tmp);
    return $params;
}	
		
?>	